//
//  ZYCModifyDutyRecordSectionHeaderView.m
//  ZDSC
//
//  Created by ZDTX on 2021/8/20.
//

#import "ZYCModifyDutyRecordSectionHeaderView.h"
#import "ZYCDutyBulletionRecordDetailModel.h"
#import "NSString+Size.h"

@interface ZYCModifyDutyRecordSectionHeaderView ()


@property (nonatomic, strong) UILabel *titleLabel;
@property (nonatomic, strong) UILabel *line;
@property (nonatomic, strong) UILabel *contenLabel;
@end
@implementation ZYCModifyDutyRecordSectionHeaderView

- (void)setModel:(ZYCBusRecordReportsModel *)model{
    _model = model;
    CGFloat height = 0.0f;
    _titleLabel.text = model.quotaName;
    
    CGSize titleSize1 = [model.quotaName sizeWithAttributes:@{NSFontAttributeName : [UIFont fontWithName:self.titleLabel.font.fontName size:self.titleLabel.font.pointSize]}];
    height += titleSize1.height;
    _contenLabel.text = model.content;
    CGSize titleSize2 = [model.content sizeWithAttributes:@{NSFontAttributeName : [UIFont fontWithName:self.contenLabel.font.fontName size:self.contenLabel.font.pointSize]}];
    //[model.content sizeWithFont:kCustomFont(@"PingFangSC-Light", 14.0f) constrainedToWidth:self.frame.size.width - 30];
    height += titleSize2.height;
    

}

- (instancetype)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self) {
        self.backgroundColor = HEX_RGB(@"FFFFFF");
        [self addSubview:self.line];
        [self addSubview:self.titleLabel];
        [self addSubview:self.contenLabel];
        [self.line mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.right.top.equalTo(self);
            make.height.mas_equalTo(1.0f);
        }];
        [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self).offset(15.5f);
            make.top.equalTo(self).offset(20.0f);
        }];
        [self.contenLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(self.titleLabel.mas_bottom).offset(15.0f);
            make.left.equalTo(self).offset(15.5f);
            make.right.equalTo(self).offset(-15.5f);
        }];
        
        [self layoutIfNeeded];
    }
    return self;
}

- (UILabel *)titleLabel {
    if (!_titleLabel) {
        _titleLabel = [UILabel LabelWithFont:kSystemBoldFont(17.0f) titleColor:HEX_RGB(@"#262A28") textAlignment:ZZTextAlignmentLeft];
    }
    return _titleLabel;
}

- (UILabel *)contenLabel {
    if (!_contenLabel) {
        _contenLabel = [UILabel LabelWithFont:kCustomFont(@"PingFangSC-Light", 14.0f) titleColor:HEX_RGB(@"#888888") textAlignment:ZZTextAlignmentLeft];
        _contenLabel.numberOfLines = 0;
    }
    return _contenLabel;
}

- (UILabel *)line {
    if (!_line) {
        _line = [[UILabel alloc] init];
        _line.backgroundColor = HEX_RGB(@"#F9F9F9");
    }
    return _line;
}

@end
